Imports CAPA_Entidad
Imports System.Data
Imports System.Data.SqlClient
Imports CAPA_Utilitarios
Public Class MensajeDatos

    'Se crea una instancia unica para las conexiones
    Dim conex As Conexion = Conexion.getInstance()

    Function leerMensajes(ByVal codPickeador As String) As String
        Dim texto As String = ""
        Dim con As SqlConnection = conex.obtenerConexion()

        Try
            con.Open()

            Dim query As String = "SELECT TOP 1 MEN_Descripcion " & _
                                  "FROM Mensaje_Pickeador " & _
                                  "WHERE MEN_Persona = '" & codPickeador & "' " & _
                                  "ORDER BY MEN_Codigo DESC"

            Dim adapter As SqlDataAdapter = New SqlDataAdapter(query, con)
            Dim ds As New DataSet
            adapter.Fill(ds)

            If ds.Tables(0).Rows.Count <> 0 Then
                texto = ds.Tables(0).Rows(0)("MEN_Descripcion").ToString.Trim
            End If
        Catch ex As Exception
            texto = "-1"
        Finally
            con.Close()
        End Try

        Return texto
    End Function

End Class
